package com.groupbuying.admin.utils.apiresult;

/**
 * @anthor  zmlmagic
 * @date    2019/1/11 3:14 PM
 * @company 蒙泰互联网公司
 * @des     接口请求返回定义
 **/

public enum ApiResultCode {
    //通用提示
    FAILURE(0, "请求失败"),
    OPRFAILURE(0, "操作失败"),
    SUCCESS(1, "请求成功"),
    OPRSUCCESS(1, "操作成功"),
    OUTLOGIN(2, "未登录"),
    ILLEGAL(3, "非法登录"),

    //统一错误码0
    FAILURE_NAMENULL(0, "用户名为空"),
    FAILURE_PASSNULL(0, "密码为空"),
    REAPEATREGIST(0, "注册中，请勿重复操作"),
    PARAMNULL(0, "请求参数为空"),
    MOBILEEXISTS(0, "手机号已存在"),
    PARAMERROR(0, "请求参数不正确"),
    SENDCODEFAILURE(0,"发送验证码失败"),
    VERIFICATIONCODEERROR(0,"验证码不正确"),
    CUSTOMERFROZEN(0,"会员已冻结"),
    CUSTOMERNOACTIVATION(0,"会员未激活"),
    CUSTOMERORPWDNOTEXISTS(0,"登录名或密码不正确"),
    LOGINNAMENOTEXISTS(0, "用户名不存在"),
    LOGINPHONENOTEXISTS(0, "该手机号尚未注册为会员"),
    RESULT_NULL(0,"结果为空"),
    USEREXPIREDORNOTEXISTS(0,"用户已过期或不存在"),
    STORENOTEXISTS(0,"商户不存在"),
    STOREACCOUNT_NOTEXISTS(0,"商户账户不存在"),
    NOTIS_STORE(0,"不是门店"),
    STORE_FROZEN(0,"门店被冻结"),
    STORE_UNAUDITED(0,"门店未审核"),
    STORE_AUDIT_REJECTED(0,"门店审核被拒"),
    COUNTER_NOTEXISTS(0,"收款台不存在"),
    COUNTER_REL_NOTEXISTS(0,"收款台当前员工不存在"),
    LOGINNAMEHAVE(0,"用户名已经存在"),
    STAFF_NOTEXISTS(0,"员工不存在"),
    STOREROLE_NOTEXISTS(0,"角色不存在"),
    ROLEEXISTDNOTDELETE(0,"角色下存在员工，不能删除"),
    STORESHOP_NOTEXISTS(0,"商户商店不存在"),
    EMPLOYEEEXISTDNOTDELETE(0,"部门下存在员工，不能删除"),
    PASSWORDERROR(0,"密码错误"),
    OLDPASSWORDERROR(0,"输入旧密码错误"),
    FILENOTEXISTS(0,"文件不存在"),
    SYSCODENOTEXISTS(0,"系统编号不存在"),
    APPLICATIONISNULL(0,"应用名称为空"),
    OSSCATELOGISNULL(0,"OSS目录为空"),
    COMPANYINFO_NOTEXISTS(0,"企业信息不完善"),
    COMPANYQUALIFICATION_NOTEXISTS(0,"企业资质信息不完善"),
    STORECAPITALVIRTUALACCOUNT_NOTEXISTS(0,"企业资金账户不完善"),

    //统一成功码1
    SUCCESS_REGISTER(1, "注册成功"),
    SUCCESS_LOGIN(1, "登录成功"),
    SUCCESS_SET(1, "设置成功"),
    SUCCESS_GETCODE(1, "验证码已发送至您手机"),

    //系统级
    CONTINUE(100, "继续"),
    SWITCHING_PROTOCOLS(101, "切换协议"),
    PROCESSING(102, "处理"),
    CHECKPOINT(103, "检查点"),
    OK(200, "OK"),
    CREATED(201, "创建"),
    ACCEPTED(202, "接受"),
    NON_AUTHORITATIVE_INFORMATION(203, "非权威信息"),
    NO_CONTENT(204, "无内容"),
    RESET_CONTENT(205, "重置内容"),
    PARTIAL_CONTENT(206, "部分内容"),
    MULTI_STATUS(207, "多状态"),
    ALREADY_REPORTED(208, "已经报告"),
    IM_USED(226, "IM 使用"),
    MULTIPLE_CHOICES(300, "多种选择"),
    MOVED_PERMANENTLY(301, "永久移动"),
    FOUND(302, "找到"),
    MOVED_TEMPORARILY(302, "Moved Temporarily"),
    SEE_OTHER(303, "见其他"),
    NOT_MODIFIED(304, "未修改"),
    USE_PROXY(305, "使用代理"),
    TEMPORARY_REDIRECT(307, "临时重定向"),
    PERMANENT_REDIRECT(308, "永久重定向"),
    BAD_REQUEST(400, "错误请求"),
    UNAUTHORIZED(401, "未经授权"),
    PAYMENT_REQUIRED(402, "需要付款"),
    FORBIDDEN(403, "禁止"),
    NOT_FOUND(404, "未找到"),
    METHOD_NOT_ALLOWED(405, "方法不允许"),
    NOT_ACCEPTABLE(406, "不可接受"),
    PROXY_AUTHENTICATION_REQUIRED(407, "需要代理验证"),
    REQUEST_TIMEOUT(408, "请求超时"),
    CONFLICT(409, "冲突"),
    GONE(410, "走了"),
    LENGTH_REQUIRED(411, "所需长度"),
    PRECONDITION_FAILED(412, "先决条件失败"),
    PAYLOAD_TOO_LARGE(413, "请求实体太大"),
    REQUEST_ENTITY_TOO_LARGE(413, "请求实体太大"),
    URI_TOO_LONG(414, "请求URI太长"),
    REQUEST_URI_TOO_LONG(414, "请求URI太长"),
    UNSUPPORTED_MEDIA_TYPE(415, "不支持的媒体类型"),
    REQUESTED_RANGE_NOT_SATISFIABLE(416, "请求范围不满足"),
    EXPECTATION_FAILED(417, "期望失败"),
    I_AM_A_TEAPOT(418, "我是茶壶"),
    INSUFFICIENT_SPACE_ON_RESOURCE(419, "资源空间不足"),
    METHOD_FAILURE(420, "方法失效"),
    DESTINATION_LOCKED(421, "目的地锁定"),
    UNPROCESSABLE_ENTITY(422, "无法处理的实体"),
    LOCKED(423, "锁定的"),
    FAILED_DEPENDENCY(424, "依赖失败"),
    UPGRADE_REQUIRED(426, "需要升级"),
    PRECONDITION_REQUIRED(428, "要求先决条件"),
    TOO_MANY_REQUESTS(429, "请求太多"),
    REQUEST_HEADER_FIELDS_TOO_LARGE(431, "请求头字段太大"),
    UNAVAILABLE_FOR_LEGAL_REASONS(451, "因法律原因无法获得"),
    INTERNAL_SERVER_ERROR(500, "内部服务器错误"),
    NOT_IMPLEMENTED(501, "未实施"),
    BAD_GATEWAY(502, "错误网关"),
    SERVICE_UNAVAILABLE(503, "服务不可用"),
    GATEWAY_TIMEOUT(504, "网关超时"),
    HTTP_VERSION_NOT_SUPPORTED(505, "不支持HTTP版本"),
    VARIANT_ALSO_NEGOTIATES(506, "变型也谈判"),
    INSUFFICIENT_STORAGE(507, "存储不足"),
    LOOP_DETECTED(508, "回路检测"),
    BANDWIDTH_LIMIT_EXCEEDED(509, "超出带宽限制"),
    NOT_EXTENDED(510, "未扩展"),
    NETWORK_AUTHENTICATION_REQUIRED(511, "需要网络认证");

    /**
     * 编码
     */
    private Integer code;
    /**
     * 消息
     */
    private String message;


    ApiResultCode(Integer code, String message) {
        this.code = code;
        this.message = message;
    }


    public Integer code() {
        return this.code;
    }


    public String message() {
        return this.message;
    }


    public static Integer getCode(String name) {
        for (ApiResultCode resultCode : ApiResultCode.values()) {
            if (resultCode.name().equals(name)) {
                return resultCode.code;
            }
        }
        return null;
    }


    public static String getMessage(String name) {
        for (ApiResultCode resultCode : ApiResultCode.values()) {
            if (resultCode.name().equals(name)) {
                return resultCode.message;
            }
        }
        return name;
    }


    @Override
    public String toString() {
        return this.name();
    }

}

